<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>复学申请详情</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody resume_detail">
        <el-form label-width="300px" ref="editForm" v-if="pageOption">
          <el-form-item label="复学审核状态:"v-if="pageOption.status">
            <el-link type="success" v-if="pageOption.status==1">通过审核</el-link>
            <el-link type="danger" v-if="pageOption.status==2">
              驳回申请{{ pageOption.content?`(${pageOption.content})`:'' }}</el-link>
          </el-form-item>
          <el-form-item label="姓名:">
            {{ pageOption.student ? pageOption.student.name : pageOption.user.realname }}
          </el-form-item>
          <el-form-item label="申报日期:">
            {{ pageOption.create_time }}
          </el-form-item>
          <el-form-item label="停学原因:">
            {{ pageOption.type==1?'病假':'事假' }}
          </el-form-item>
          <el-form-item label="学生体温:">
            <span :style="{'color':Number(pageOption.temperature)>37.3?'red':''}"> {{ pageOption.temperature }}°C</span>
          </el-form-item>
          <el-form-item label="是否健康:">
            {{ pageOption.is_health == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="是否接种疫苗:">
            {{ pageOption.is_vaccines == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="您及您的家人14天内是否从高风险地区来厦:">
            {{ pageOption.is_in == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="您及您的家人14天内是否出境:">
            {{ pageOption.is_other_green == 1 ? '是' : '否' }}
          </el-form-item>
          <el-form-item label="当前是否在厦:">
            {{ pageOption.is_local == 1 ? '是' : '否' }}
          </el-form-item>
          <!--          图片-->
<!--          // medical_record: '', // 病例-->
<!--          //     nuclein: '', // 核酸-->
<!--          //     trip_code: '' // 形成吗-->
<!--          // health_code: '', // 	整型 	必填 	1 	- 	健康码-->
<!--          //     qr_code: '', // 	整型 	必填 	1 	- 	其他人健康码-->
          <el-form-item label="学生健康码:">
            <viewer :images="pageOption.health_code" class="descimgBox" v-if="pageOption.health_code && pageOption.health_code.length">
              <img v-for="(decImg, index) in pageOption.health_code" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="共同居住人健康码:">
            <viewer :images="pageOption.qr_code" class="descimgBox" v-if="pageOption.qr_code && pageOption.qr_code.length">
              <img v-for="(decImg, index) in pageOption.qr_code" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="行程码:" v-if="pageOption.type==1">
            <viewer :images="pageOption.trip_code" class="descimgBox" v-if="pageOption.trip_code && pageOption.trip_code.length">
              <img v-for="(decImg, index) in pageOption.trip_code" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="核酸报告:" v-if="pageOption.type==1">
            <viewer :images="pageOption.nuclein" class="descimgBox" v-if="pageOption.nuclein && pageOption.nuclein.length">
              <img v-for="(decImg, index) in pageOption.nuclein" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
          <el-form-item label="康复证明(提示:二级卫生机构出具):" v-if="pageOption.type==1">
            <viewer :images="pageOption.medical_record" class="descimgBox" v-if="pageOption.medical_record && pageOption.medical_record.length">
              <img v-for="(decImg, index) in pageOption.medical_record" :key="index" :src="decImg" class="viewerImg">
            </viewer>
            <p v-else>未提交</p>
          </el-form-item>
        </el-form>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="small">返回</el-button>
        <el-button type="primary" size="small" @click="examinBtn(0)" plain v-if="pageOption && !pageOption.status">
          通过
        </el-button>
        <el-button size="small" @click="examinBtn(1)" class="ml-10" plain type="danger" v-if="pageOption && !pageOption.status">驳回
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {resumeDetail, resumeExamine} from '@/api/admin/student_resume'

export default {
  props: ['visible', 'resumeId'],
  components: {},
  data() {
    return {
      dialogVisible: false,
      // 页数
      tableHeight: 0,
      pageOption: null,
      tripCode: [],
      studentPhoto: [],
      familyPhoto: [],
      unclein: [],
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible;
      if (this.visible) {
        this.InitFn();
      } else {
        this.pageOption = '';
        this.studentPhoto = [];
        this.familyPhoto = [];
        this.tripCode = [];
      }
    }
  },
  created() {
  },
  methods: {
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    examinBtn(type) {
      let that = this;
      if (type === 0) {
        this.$confirm('确认复学的审核, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          that.subimitExamin(type)
        }).catch(() => {

        });
      } else {
        this.$prompt('输入驳回说明', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({value}) => {
          // value
          that.subimitExamin(type, value)
        }).catch(() => {

        });
      }
    },
    subimitExamin(type, value) {
      let n = this;
      // 0 通过 1 驳回
      let option = {id: this.resumeId, type: type}
      if (type === 1) {
        option.content = value;
      }
      resumeExamine(option).then(res => {
        if (!res.code) {
          this.InitFn();
          n.$message.success(res.msg)
          n.$emit('InitFn')
        } else {
        }
      })
    },
    // 初始化
    async InitFn() {
      resumeDetail({id: this.resumeId}).then(res => {
        console.log(res)
        //     nuclein: '', // 核酸
        //     trip_code: '' // 形成吗
        // health_code: '', // 	整型 	必填 	1 	- 	健康码
        //     qr_code: '', // 	整型 	必填 	1 	- 	其他人健康码

        let option = JSON.parse(JSON.stringify(res.vo))
        if(option.type===1 && option.medical_record){
          option.medical_record = []
          for(let item of JSON.parse(JSON.stringify(res.vo.medical_record.split(',')))){
            option.medical_record.push(`${item}`)
          }
        }
        if(option.type===1 && option.nuclein){
          option.nuclein = []
          for(let item of JSON.parse(JSON.stringify(res.vo.nuclein.split(',')))){
            option.nuclein.push(`${this.imgUploadSrc}${item}`)
          }
        }
        if(option.type===1 && option.trip_code){
          option.trip_code = []
          for(let item of JSON.parse(JSON.stringify(res.vo.trip_code.split(',')))){
            option.trip_code.push(`${this.imgUploadSrc}${item}`)
          }
        }
        if(option.health_code){
          option.health_code = []
          for(let item of JSON.parse(JSON.stringify(res.vo.health_code.split(',')))){
            option.health_code.push(`${this.imgUploadSrc}${item}`)
          }
        }
        if(option.qr_code){
          option.qr_code = []
          for(let item of JSON.parse(JSON.stringify(res.vo.qr_code.split(',')))){
            option.qr_code.push(`${this.imgUploadSrc}${item}`)
          }
        }
        console.log('res.vo:', option)
        this.pageOption = option
      })
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 70%;
  height: 75%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}

.hearder-search {
  display: flex;
  align-items: center;
}

.viewerImg {
  width: 100px;
}
</style>


